<template>
  <div class="ocn-notice">
    <div class="icon">
      <img src="@/assets/newhome/1.png" alt srcset />
    </div>
    <div class="marquee-wrap" @click="$router.push('/noticeList')">
      <ul class="marquee-list" :class="{'animate-up': animateUp}">
        <li v-for="(item, index) in listData" :key="index">{{item}}</li>
      </ul>
    </div>
  </div>
</template>
<script>
export default {
  name: "OcnNotice",
  data() {
    return {
      animateUp: false,
      timer: null
    };
  },
  props: {
    listData: {
      type: Array,
      default: ["暂无通知公告"]
    }
  },
  mounted() {
    this.timer = setInterval(this.scrollAnimate, 1500);
  },
  methods: {
    scrollAnimate() {
      this.animateUp = true;
      setTimeout(() => {
        this.listData.push(this.listData[0]);
        this.listData.shift();
        this.animateUp = false;
      }, 500);
    }
  },
  destroyed() {
    clearInterval(this.timer);
  }
};
</script>
<style lang="scss" scoped>
@import "~@/smobile.scss";
.ocn-notice {
  display: flex;
  background: #fffbe8;
  .icon{
      width: 22px;
      height: 18px;
      margin-top: 11px;
      margin-left: 15px;
      img{
          width: 100%;
      }
  }
  .marquee-wrap {
    flex: 1;
    height: 40px;
    margin: 0 auto;
    overflow: hidden;
    .marquee-list {
      li {
        width: 100%;
        height: 100%;
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
        padding: 0 20px;
        list-style: none;
        line-height: 40px;
        text-align: left;
        color: #ed6a0c;
        font-size: 12px;
        font-weight: 400;
      }
    }
    .animate-up {
      transition: all 0.5s ease-in-out;
      transform: translateY(-40px);
    }
  }
}
</style>